define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'article.article/index',
        add_url: 'article.article/add',
        edit_url: 'article.article/edit',
        delete_url: 'article.article/delete',
        export_url: 'article.article/export',
        modify_url: 'article.article/modify'
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                ],
                cols: [[
                    { field: 'id', title: 'ID', width: 80 }
                    , { field: 'title', title: '标题', width: 180 }
                    , { field: 'att_title', title: '副标题', width: 180 }
                    , { field: 'text', title: '正文', width: 180 }
                    , { field: 'banner', title: '是否横幅(0否,1是)', width: 180 }
                    , { field: 'image', title: '封面图', width: 180 }
                    , { field: 'cor_article', title: '关联文章id', width: 100 }
                    , { field: 'sort', title: '排序', width: 80 }
                    , { field: 'virtually_read', title: '虚拟阅读', width: 120 }
                    , { field: 'true_read', title: '实际阅读量', width: 120 },
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }],
                            'delete']
                    }
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        stock: function () {
            ea.listen();
        },
    };
    return Controller;
});